<?php 
require_once("../include/conn.php");
//提取当前所有栏目信息
//$sql_all="select * from $tb_bm";
//$all_conn=mysql_query($sql_all);

if($_REQUEST["action"] == "update")
{	
	
	$id=$_REQUEST["id"];
	//提取栏目信息
	//echo $id;
	$sql_lanmu="select * from $tb_bm where id='".$id."'";
	$lanmu_conn=mysql_query($sql_lanmu);
	if($lanmu_row=mysql_fetch_row($lanmu_conn)){
?>
		<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
		<html>
		<head>
		<script language="javascript" src="checkinfo.js"></script>
		
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>无标题文档</title>
		<link href="Admin_Style.css" rel="stylesheet" type="text/css">
		</head>
		<body>
		<form action="update_lanmu.php?id=<?php echo $id; ?>" method="post"  name="myform" onSubmit="return Checked();">
		  <table width="100%"  border="0" cellpadding="0" cellspacing="4" class="tdbg">
			<tr>
			  <th colspan="2" class="topbg">信息发布</th>
			</tr>
			<tr>
			  <td align="right">上级栏目名称</td>
			  <td><select name="name" id="name">
	  <option value=10&isindex=1 >学习天地</option>
        <?php  
				        //提取三级栏目信息
		$sql_parent="select * from $tb_bm where  parentid='10'";
		$parent_conn=mysql_query($sql_parent);
		while($parent_row=mysql_fetch_array($parent_conn)){
			echo "<option value='".$parent_row[id]."&isindex=2'  >&nbsp;&nbsp;->".$parent_row[buname]."</option>\n";
			if($id==$parent_row[id]) echo "  selected";
			echo " >".$parent_row[buname]."</option>\n";

			
			
			//if($parent_row[parentid]>0 && $parent_row[isindex]>1){
				//提取子栏目栏目信息				
				/*
				$sql_child="select * from $tb_bm where isindex='3' and  parentid='".$parent_row[id]."'";
				
				$child_conn=mysql_query($sql_child);
				while($child_row=mysql_fetch_array($child_conn)){
					echo "<option value='".$child_row[id]."&isindex=3' ";
					if($id==$child_row[id]) echo "  selected";
					echo " >&nbsp;&nbsp;->".$child_row[buname]."</option>\n";				
				}*/
			//}			
				 
		  }

		?>
      </select>
		      如果顶级栏目请选择“无上级栏目”项，若创建子栏目请选择其上级栏目。</td>
		    </tr>
			<tr>
			  <td width="164" align="right">栏目名称：</td>
			  <td width="770"><input name="buname" type="text" id="buname" value="<?php echo $lanmu_row[1] ?>" size="20">
				<span class="redtxt">*</span></td>
			</tr>	
			
			<tr>
			  <td align="right">&nbsp;</td>
			  <td><input type="submit" name="Submit" value="提交">
			  <input name="benid" type="hidden" value="<?php echo $lanmu_row[0] ?>">
			  <input name="benindex" type="hidden" value="<?php echo $lanmu_row[2] ?>">
				<input name="action" type="hidden" id="action" value="update">
			  <input type="reset" name="Submit" value="重置"></td>
			</tr>
		  </table>
		</form>
		</body>
		</html>

<?php 
	}else{
		
		echo "<script language=\"JavaScript\" type=\"text/JavaScript\">";
		echo "alert(\"参数不全!\");";
		echo "</script>"; 		
		 echo "<script language='javascript'>";
		 echo "self.location="."'"."admin_index.php'";
		 echo "</script>"; 
	}
}
else{	

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script language="javascript" src="checkinfo.js"></script>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<link href="Admin_Style.css" rel="stylesheet" type="text/css">
</head>
<body>
<form action="update_lanmu.php" method="post"  name="myform" onSubmit="return Checked();">
  <table width="100%"  border="0" cellpadding="0" cellspacing="4" class="tdbg">
    <tr>
      <th colspan="2" class="topbg">信息发布</th>
    </tr>
	<tr>
	  <td align="right">上级栏目名称</td>
	  <td><select name="name" id="name">
	  <option value=10&isindex=1 >学习天地</option>
        <?php  
				        //提取三级栏目信息
		$sql_parent="select * from $tb_bm where  parentid='10'";
		$parent_conn=mysql_query($sql_parent);
		while($parent_row=mysql_fetch_array($parent_conn)){
			echo "<option value='".$parent_row[id]."&isindex=2'  >&nbsp;&nbsp;->".$parent_row[buname]."</option>\n";
				//提取子栏目栏目信息				
				//三级子栏目不需要显示
				/*
				$sql_child="select * from $tb_bm where isindex='3' and  parentid='".$parent_row[id]."'";
				$child_conn=mysql_query($sql_child);
				while($child_row=mysql_fetch_array($child_conn)){
					echo "<option value='".$child_row[id]."&isindex=3'   >&nbsp;&nbsp;&nbsp;&nbsp;->".$child_row[buname]."</option>\n";
				}	
				*/			 
		  }

		?>
      </select>
		      本程序创建栏目均为“学习天地”的下级栏目，若创建子栏目请选择其上级栏目。</td>
		</tr>
    <tr>
      <td width="164" align="right">栏目名称：</td>
      <td width="770"><input name="buname" type="text" id="buname" size="20">
        <span class="redtxt">*</span></td>
    </tr>	
    
    <tr>
      <td align="right">&nbsp;</td>
      <td><input type="submit" name="Submit" value="提交">
        <input name="action" type="hidden" id="action" value="add">
      <input type="reset" name="Submit" value="重置"></td>
    </tr>
  </table>
</form>
</body>
</html>
<?php 
}
?>
